package adapter

import "strconv"

// 要适配的对象接口
type Adaptee interface {
	SpecRequest(int, int) string
}

type AdapteeImpl struct {
}

func (ap *AdapteeImpl) SpecRequest(a, b int) string {
	return strconv.Itoa(a + b)
}

func NewAdaptee() Adaptee {
	return &AdapteeImpl{}
}

// 目标接口
type Target interface {
	Request(int, int) string
}

// 适配器接口
type Adapter interface {
	Adaptee
	Target
}

type AdapterImpl struct {
	Adaptee
}

func (ta *AdapterImpl) Request(a, b int) string {
	return ta.SpecRequest(a, b)
}

func NewAdapter(ad Adaptee) Target {
	return &AdapterImpl{ad}
}
